﻿<controls:ChildWindow 
           x:Class="AdminModule.Views.SelectAddItemsWindow"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:usercontrols="clr-namespace:AdminModule.UserControls.Common"
           xmlns:common="clr-namespace:System.Windows;assembly=System.Windows.Controls"
           xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
           xmlns:converters="clr-namespace:AdminModule.Converters"
           Width="720" Height="520"
           Loaded="ChildWindow_Loaded"
           Title="Выберите объекты">
    
    <controls:ChildWindow.Resources>

        <converters:EmptyStringToLineConverter x:Key="emptyStringToLineConverter"></converters:EmptyStringToLineConverter>
        <converters:NullToBlankConverter x:Key="nullToBlankConverter"></converters:NullToBlankConverter>

        <DataTemplate x:Key="AdmCharacteristic">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock TextWrapping="Wrap" Width="640" Text="{Binding Name}">
                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDCharacteristic: "></TextBlock>
                            <TextBlock Text="{Binding ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </TextBlock>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="AdmGradation">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock TextWrapping="Wrap" Width="640" Text="{Binding Name}">
                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDGradation: "></TextBlock>
                            <TextBlock Text="{Binding ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </TextBlock>
            </StackPanel>
        </DataTemplate>

        <DataTemplate x:Key="AdmDepartment">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock Text="{Binding FullName}"></TextBlock>
                <TextBlock Text=" ("></TextBlock>
                <TextBlock Text="{Binding Abbriviation}"></TextBlock>
                <TextBlock Text=")"></TextBlock>

                <ToolTipService.ToolTip>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="IDDepartment: "></TextBlock>
                        <TextBlock Text="{Binding IDDepartment}"></TextBlock>
                    </StackPanel>
                </ToolTipService.ToolTip>
            </StackPanel>
        </DataTemplate>

        <!--AdmGradationsStructSelectGroup-->
        <common:HierarchicalDataTemplate x:Key="otherGradationsSelectGroup" ItemsSource="{Binding Childs}">
            <StackPanel Orientation="Horizontal">
                <TextBlock FontStyle="Italic" Padding="0" Text="{Binding Path=Order}" />
                <TextBlock FontStyle="Italic" Padding="0" Text=". "/>
                <TextBlock Padding="0" Text="{Binding Path=Name}" />
                <TextBlock Padding="0" Text=" (вес: "/>
                <TextBlock Padding="0" Text="{Binding Path=Weight}" />
                <TextBlock Padding="0" Text=")"/>

                <ToolTipService.ToolTip>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="IDGradationTerm: "></TextBlock>
                        <TextBlock Text="{Binding IDGradationTerm}"></TextBlock>
                        <TextBlock Text=", IDGradation: "></TextBlock>
                        <TextBlock Text="{Binding ID}"></TextBlock>
                    </StackPanel>
                </ToolTipService.ToolTip>
            </StackPanel>
        </common:HierarchicalDataTemplate>

        <common:HierarchicalDataTemplate x:Key="AdmGradationsStructSelectGroup" ItemsSource="{Binding Childs}" ItemTemplate="{StaticResource otherGradationsSelectGroup}">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock FontStyle="Italic" Padding="0" Text="{Binding Path=Order}" />
                <TextBlock FontStyle="Italic" Padding="0" Text=". "/>
                <TextBlock FontStyle="Italic" TextWrapping="Wrap" MaxWidth="600" Padding="0" Text="{Binding Path=Name}" />
                <TextBlock FontStyle="Italic" Padding="0" Text=" (вес: "/>
                <TextBlock FontStyle="Italic" Padding="0" Text="{Binding Path=Weight}" />
                <TextBlock FontStyle="Italic" Padding="0" Text=")"/>

                <ToolTipService.ToolTip>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="IDGradationTerm: "></TextBlock>
                        <TextBlock Text="{Binding IDGradationTerm}"></TextBlock>
                        <TextBlock Text=", IDGradation: "></TextBlock>
                        <TextBlock Text="{Binding ID}"></TextBlock>
                    </StackPanel>
                </ToolTipService.ToolTip>
            </StackPanel>
        </common:HierarchicalDataTemplate>
        <!-- / AdmGradationsStructSelectGroup-->

        <!--AdmGradationsStruct-->
        <common:HierarchicalDataTemplate x:Key="otherGradations" ItemsSource="{Binding Childs, Mode=TwoWay}">
            <CheckBox Tag="{Binding}" x:Name="checkBoxHierarchical" IsEnabled="{Binding Enabled, Mode=TwoWay}" Click="checkBoxHierarchical_Click" IsChecked="{Binding Checked, Mode=TwoWay}">
                <StackPanel Orientation="Horizontal">
                    <TextBlock Padding="0" Text="{Binding Path=Order}" />
                    <TextBlock Padding="0" Text=". "/>
                    <TextBlock Padding="0" Text="{Binding Path=Name}" />
                    <TextBlock Padding="0" Text=" (вес: "/>
                    <TextBlock Padding="0" Text="{Binding Path=Weight}" />
                    <TextBlock Padding="0" Text=")"/>

                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDGradationTerm: "></TextBlock>
                            <TextBlock Text="{Binding IDGradationTerm}"></TextBlock>
                            <TextBlock Text=", IDGradation: "></TextBlock>
                            <TextBlock Text="{Binding ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </StackPanel>
            </CheckBox>
        </common:HierarchicalDataTemplate>

        <common:HierarchicalDataTemplate x:Key="AdmGradationsStruct" ItemsSource="{Binding Childs, Mode=TwoWay}" ItemTemplate="{StaticResource otherGradations}">
            <StackPanel Orientation="Horizontal">
                    <RadioButton Tag="{Binding}" x:Name="radioButtonHierarchical" Loaded="Button_Loaded" Click="radioButtonHierarchical_Click" IsChecked="{Binding Checked, Mode=TwoWay}" />
                    <CheckBox Tag="{Binding}" x:Name="checkBoxHierarchical_1" Loaded="Button_Loaded" Click="checkBoxHierarchical_Click_1" IsChecked="{Binding Checked, Mode=TwoWay}" />

                    <StackPanel Orientation="Horizontal">
                    <TextBlock FontStyle="Italic" Padding="0" Text="{Binding Path=Order}" />
                    <TextBlock FontStyle="Italic" Padding="0" Text=". "/>
                    <TextBlock FontStyle="Italic" TextWrapping="Wrap" Width="600" Padding="0" Text="{Binding Path=Name}" />
                    <TextBlock FontStyle="Italic" Padding="0" Text=" (вес: "/>
                    <TextBlock FontStyle="Italic" Padding="0" Text="{Binding Path=Weight}" />
                    <TextBlock FontStyle="Italic" Padding="0" Text=")"/>

                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDGradationTerm: "></TextBlock>
                            <TextBlock Text="{Binding IDGradationTerm}"></TextBlock>
                            <TextBlock Text=", IDGradation: "></TextBlock>
                            <TextBlock Text="{Binding ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </StackPanel>
            </StackPanel>
        </common:HierarchicalDataTemplate>
        <!-- / AdmGradationsStruct-->

        <DataTemplate x:Key="AdmSection">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock TextWrapping="Wrap" Width="640" Text="{Binding Name}">
                    <ToolTipService.ToolTip>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="IDSection: "></TextBlock>
                            <TextBlock Text="{Binding ID}"></TextBlock>
                        </StackPanel>
                    </ToolTipService.ToolTip>
                </TextBlock>
            </StackPanel>
        </DataTemplate>
        
        <DataTemplate x:Key="AdmPerson">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock Text="{Binding LastName}"></TextBlock>
                <TextBlock Text=" "></TextBlock>
                <TextBlock Text="{Binding FirstName}"></TextBlock>
                <TextBlock Text=" "></TextBlock>
                <TextBlock Text="{Binding Patronymic}"></TextBlock>

                <ToolTipService.ToolTip>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="IDPerson: "></TextBlock>
                        <TextBlock Text="{Binding IDPerson}"></TextBlock>
                    </StackPanel>
                </ToolTipService.ToolTip>
            </StackPanel>
        </DataTemplate>
        
        <DataTemplate x:Key="AdmResponsible">
            <StackPanel Orientation="Horizontal">
                <RadioButton Tag="{Binding}" x:Name="radioButton" Checked="radioButton_Checked" Loaded="Button_Loaded" GroupName="gradationGroup" VerticalAlignment="Center" />
                <CheckBox Tag="{Binding}" x:Name="checkBox" Checked="checkBox_Checked" Unchecked="checkBox_Unchecked" Loaded="Button_Loaded" VerticalAlignment="Center" IsChecked="{Binding Path=Checked}" />

                <TextBlock Text="{Binding Path=Position.Name}"></TextBlock>
                <TextBlock Text=" ("></TextBlock>
                <!--Вставим тире, если отдел == NULL-->
                <TextBlock ToolTipService.ToolTip="Отдел" Text="{Binding Path=Department, Converter={StaticResource nullToBlankConverter}}"></TextBlock>
                <!--<TextBlock ToolTipService.ToolTip="Отдел" Text="{Binding Path=Department.Name}"></TextBlock>-->
                <TextBlock ToolTipService.ToolTip="Отдел" Text="{Binding Path=Department.FullName}"></TextBlock>
                <TextBlock Text=")"></TextBlock>

                <ToolTipService.ToolTip>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="IDResponsible: "></TextBlock>
                        <TextBlock Text="{Binding IDResponsible}"></TextBlock>
                    </StackPanel>
                </ToolTipService.ToolTip>
            </StackPanel>
        </DataTemplate>

    </controls:ChildWindow.Resources>
    
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <usercontrols:ProgressBar IsVisibility="Collapsed" VerticalAlignment="Center" HorizontalAlignment="Center" x:Name="progressBar"></usercontrols:ProgressBar>
        <StackPanel Orientation="Horizontal" Grid.Row="1" VerticalAlignment="Bottom">
            <TextBlock Text="Прототип фильтра: " />
            <TextBox Name="_tFilter" MinWidth="55"/>            
        </StackPanel>

        <!--Для плоских данных-->
        <ListBox Visibility="Collapsed" x:Name="listBox" />
        <!--Для иерархических данных-->
        <controls:TreeView Visibility="Collapsed" x:Name="treeView" />
        
        <Button x:Name="CancelButton" Content="Отмена" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
    </Grid>
</controls:ChildWindow>